package com.service.admin.base.controller;

import com.service.admin.base.controller.req.MemberGradeDeleteReq;
import com.service.admin.base.service.MemberGradeConfigService;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.MultiResponse;
import com.service.core.rest.response.OneResponse;
import com.service.dao.model.MemberGradeConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 会员等级
 *
 * @author xxxx
 * @email xxxx@qq.com
 * @date 2019-11-27 22:39:19
 */
@RestController
@RequestMapping("config/member-grade")
public class MemberGradeConfigController extends BaseController {

    @Autowired
    private MemberGradeConfigService memberGradeConfigService;

    /**
     * 会员等级
     * 列表
     *
     * @author xxxx
     * @email xxxx@qq.com
     * @date 2019-11-27 22:39:19
     */
    @GetMapping("/list")
    public MultiResponse<MemberGradeConfig> listAll() {
        return successQueryMultiResponse(memberGradeConfigService.list());
    }

    /**
     * 会员等级
     * 信息
     *
     * @author xxxx
     * @email xxxx@qq.com
     * @date 2019-11-27 22:39:19
     */
    @GetMapping("/load/{id}")
    public OneResponse<MemberGradeConfig> load(@PathVariable("id") Integer id) {
        return successQueryOneResponse(memberGradeConfigService.getById(id));
    }

    /**
     * 会员等级
     * 保存
     *
     * @author xxxx
     * @email xxxx@qq.com
     * @date 2019-11-27 22:39:19
     */
//    @PostMapping("/create")
   /* public BaseResponse create(@RequestBody MemberGradeConfig memberGradeConfig) {
        memberGradeConfigService.save(memberGradeConfig);
        return successBaseResponse();
    }*/

    /**
     * 会员等级
     * 修改
     *
     * @author xxxx
     * @email xxxx@qq.com
     * @date 2019-11-27 22:39:19
     */
    @PostMapping("/modify")
    public BaseResponse modify(@RequestBody MemberGradeConfig memberGradeConfig) {
        memberGradeConfigService.updateById(memberGradeConfig);
        return successUpdateBaseResponse();
    }

    /**
     * 会员等级
     * 删除
     *
     * @author xxxx
     * @email xxxx@qq.com
     * @date 2019-11-27 22:39:19
     */
    @PostMapping("/remove")
    public BaseResponse remove(@RequestBody MemberGradeDeleteReq ids) {
        memberGradeConfigService.removeByIds(ids.getIds());
        return successBaseResponse();
    }
}
